﻿using System;

    class MatrixUI
    {
        //Exercise 6*.
        //Write a class Matrix, to holds a matrix of integers. Overload the operators for adding, subtracting and 
        //multiplying of matrices, indexer for accessing the matrix content and ToString().

        static void Main()
        {
            Matrix matrix1 = new Matrix(3, 3);
            matrix1[0, 0] = 1;
            matrix1[0, 2] = 8;
            matrix1[1, 1] = -12;
            matrix1[1, 2] = 6;
            matrix1[2, 0] = 5;
            matrix1[2, 1] = 20;            

            Matrix matrix2 = new Matrix(3, 3);
            
            matrix2[0, 1] = 2;
            matrix2[1, 1] = 24;

            Matrix sum = matrix1 + matrix2;
            PrintMatrix(sum);

            //alternative way to print
            Console.WriteLine(sum.ToString());

            Matrix subtract = matrix1 - matrix2;
            PrintMatrix(subtract);

            Console.WriteLine();

            Matrix multiply = matrix1 * matrix2;
            PrintMatrix(multiply);
        }

        static void PrintMatrix(Matrix matrix)
        {
            for (int row = 0; row < matrix.Rows; row++)
            {
                for (int col = 0; col < matrix.Columns; col++)
                {
                    Console.Write(matrix[row, col] + " ");
                }

                Console.WriteLine();
            }
        }
    }

